<template>
  <div class="class-nav-com">
    <div v-show="showDelete" class="list-item-delete">
      <span class="pull_left">{{ item.text }}</span>
      <span class="pull_right" @click.stop="deleteCurItem(item, index)"
        >删除</span
      >
    </div>
    <div v-if="item.stylesType == 2" class="styleOne">
      <div v-for="(imgItem, imgIndex) in imgArr" :key="imgIndex">
        <img :src="imgItem.src" />
        <p>{{ imgItem.substance }}</p>
      </div>
    </div>
    <div v-if="item.stylesType == 1" class="styleOne">
      <div v-for="(imgItem, imgIndex) in imgArr1" :key="imgIndex">
        <img :src="imgItem.src" />
        <p>{{ imgItem.substance }}</p>
      </div>
    </div>
    <div v-if="item.stylesType == 0" class="styleOne">
      <div v-for="(imgItem, imgIndex) in item.imgUrls" :key="imgIndex">
        <img :src="imgItem.src" />
        <p>{{ imgItem.substance }}</p>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    item: {
      type: Object,
      default: () => {}
    },
    index: {
      type: Number,
      default: -1
    },
    showDelete: {
      type: Boolean,
      default: false
    }
  },
  computed: {
    imgArr() {
      let arr = this.item.imgUrls.filter((ele, i) => {
        if (i < 3) return ele;
      });
      return arr;
    },
    imgArr1() {
      let arr = this.item.imgUrls.filter((ele, i) => {
        if (i < 4) return ele;
      });
      return arr;
    }
  },
  methods: {
    deleteCurItem(e, i) {
      this.$emit("deleteCurItem", e, i);
    }
  }
};
</script>

<style lang="scss" scoped>
.class-nav-com {
  position: relative;
  font-size: 12px;
  color: #595961;
  padding: 10px;
  background-color: #fff;
  text-align: center;
  img {
    width: 50px;
    height: 50px;
    margin: 0 auto 10px auto;
  }
  .styleOne {
    display: flex;
    justify-content: space-between;
  }
}
</style>
